﻿<UserControl x:Class="StockTraderRI.Modules.News.Article.ArticleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
     HorizontalAlignment="Left">
    <UserControl.Resources>
        <!-- By convention every view inside the ResearchControl (ResearchRegion) has to declare 
             a DataTemplate with the "HeaderIcon" key which defines the icon on the Header -->
        <DataTemplate x:Key="HeaderIcon">
            <Grid Margin="15,5,0,0" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="14.5" Height="16.375">
                <Path Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2" Data="M409.875,447.625 L409.875,433.25 418.625,433.25 422.375,437 422.375,447.625 z"/>
                <Path Margin="2.75,0,2.625,4.25" VerticalAlignment="Bottom" Height="2" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2" Data="M328.625,443.375 L335.75,443.375"/>
                <Path Margin="2.75,6.375,2.625,8" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2" Data="M328.625,443.375 L335.75,443.375"/>
            </Grid>
        </DataTemplate>
        <Style x:Key="ArticleItemStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <ContentPresenter/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="ArticleDataTemplate">
            <StackPanel Margin="0,0,0,10" Width="230" Cursor="Hand" HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=PublishedDate}" Foreground="#FF808080" FontFamily="Trebuchet MS" FontSize="12"/>
                <TextBlock Text="{Binding Path=Title}" Foreground="#FF808080" FontFamily="Trebuchet MS" FontSize="14" TextWrapping="Wrap" />
            </StackPanel>
        </DataTemplate>
        <ControlTemplate x:Key="BackButtonTemplate" TargetType="Button">
            <StackPanel HorizontalAlignment="Center"  VerticalAlignment="Center" Background="#00000000" Width="22" Height="22">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="FocusStates">
                        <vsm:VisualState x:Name="Unfocused"/>
                        <vsm:VisualState x:Name="Focused"/>
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="CommonStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.1000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle2" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Normal"/>
                        <vsm:VisualState x:Name="Pressed">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle2" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Disabled"/>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Rectangle x:Name="rectangle" Height="3" Margin="0,2,0,2" Width="22" Fill="#FFA6A6A6" StrokeThickness="0" RadiusX="2" RadiusY="2"/>
                <Rectangle x:Name="rectangle1" Height="3" Width="22" Fill="#FFA6A6A6" StrokeThickness="0" RadiusX="2" RadiusY="2" Margin="0,2,0,2"/>
                <Rectangle x:Name="rectangle2" Height="3" Width="22" Fill="#FFA6A6A6" StrokeThickness="0" RadiusX="2" RadiusY="2" Margin="0,2,0,2"/>
            </StackPanel>
        </ControlTemplate>
        <ControlTemplate x:Key="OpenButtonTemplate" TargetType="Button">
            <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Background="#00000000" Width="22" Height="22">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="FocusStates">
                        <vsm:VisualState x:Name="Unfocused"/>
                        <vsm:VisualState x:Name="Focused"/>
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="CommonStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.1000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path1" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path2" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Normal"/>
                        <vsm:VisualState x:Name="Pressed">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path1" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path2" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Disabled"/>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Path x:Name="path" Data="M0,1 L11,1 L11,3 L2,3 L2,18 L17,18 L17,9 L19,9 L19,20 L0,20 z" Fill="#FFA6A6A6" Stretch="Fill" StrokeThickness="0" Margin="2,3,3,2"/>
                <Path x:Name="path2" Height="14" Width="14" Data="M8,12 L20,0" Stretch="Fill" Stroke="#FFA6A6A6" StrokeThickness="2" Margin="0,-6,-6,0"/>
                <Path x:Name="path1" Height="7" Width="7" Data="M0,0 L7,0 L7,7 z" Fill="#FFA6A6A6" Stretch="Fill" StrokeThickness="2" Margin="0,-13,-13,0"/>
            </Grid>
        </ControlTemplate>
    </UserControl.Resources>
    <Border Padding="10,10,10,10">
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="Common">
                <vsm:VisualStateGroup.Transitions>
                    <vsm:VisualTransition GeneratedDuration="00:00:00" To="Details"/>
                    <vsm:VisualTransition GeneratedDuration="00:00:00" To="List"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="List">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ListGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.6000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ListGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                            <SplineDoubleKeyFrame KeySpline="0.5,0,0.5,1" KeyTime="00:00:00.6000000" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DetailsGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DetailsGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                            <SplineDoubleKeyFrame KeySpline="0.5,0,0.5,1" KeyTime="00:00:00.3000000" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Details">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ListGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" KeySpline="0.5,0,0.5,1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ListGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DetailsGrid" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.3000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.6000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DetailsGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="1" KeySpline="0.5,0,0.5,1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
        <StackPanel>
            <Grid x:Name="ListGrid" RenderTransformOrigin="0.5,0.5" Width="240">
                <Grid.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </Grid.RenderTransform>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="NEWS ARTICLES" Style="{StaticResource TextBlockSectionTitle}" AutomationProperties.AutomationId="NewsArticleText" />
                    <ListBox Grid.Row="1" BorderThickness="0"  ItemsSource="{Binding Path=Articles}"
    					ItemTemplate="{StaticResource ArticleDataTemplate}"
    					ItemContainerStyle="{StaticResource ArticleItemStyle}" ScrollViewer.VerticalScrollBarVisibility="Hidden"
                        x:Name="NewsList"
    					SelectedItem="{Binding Mode=TwoWay, Path=SelectedArticle}" Margin="0,0,0,0" Background="{x:Null}" BorderBrush="{x:Null}" SelectionChanged="ListBox_SelectionChanged"/>
            </Grid>
            <Grid x:Name="DetailsGrid" Visibility="Collapsed" RenderTransformOrigin="0.5,0.5" Width="240" DataContext="{Binding Path=SelectedArticle}" >
                <Grid.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </Grid.RenderTransform>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Text="{Binding Path=Title}" Style="{StaticResource TextBlockSectionTitle}" TextWrapping="Wrap" MaxWidth="170" HorizontalAlignment="Left" />
                <TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding Path=Body}" Foreground="#FF808080" FontFamily="Trebuchet MS" FontSize="12" TextWrapping="Wrap" />
                <StackPanel Height="22" Grid.Column="1" Grid.Row="0" d:LayoutOverrides="GridBox" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
                    <Button Click="BackButton_Click" Template="{StaticResource BackButtonTemplate}" Cursor="Hand" Content="{StaticResource BackButtonTemplate}" HorizontalAlignment="Left" />
                    <Button Click="OpenButton_Click" Template="{StaticResource OpenButtonTemplate}" Cursor="Hand" Content="{StaticResource OpenButtonTemplate}" HorizontalAlignment="Left" Margin="5,0,0,0" />
                </StackPanel>
            </Grid>
        </StackPanel>
    </Border>
</UserControl>
